/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.dao.impl.common.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.sigmatrix.h5.dao.impl.common.BaseMongoDao;

/**
 *@ClassName: BaseMongoDaoImpl
 *@Description: TODO()
 *@author youjun
 *@date 2017年6月29日 上午10:46:59
 */
public class BaseMongoDaoImpl<T extends Serializable> implements BaseMongoDao<T> {

	/**注入mongoTemplate进行mongo db的操作*/
	@Autowired
	protected transient MongoTemplate mongoTemplate;
	
	/**(non-Javadoc)
	 *@Title: save
	 *@Description: 
	 *@see com.sigmatrix.sc.handheld.inter.dao.impl.common.BaseMongoDao#save(java.io.Serializable)
	 *@author youjun
	 *@date 2017年6月29日 上午10:47:20
	 */
	@Override
	public void save(T entity) {
		mongoTemplate.save(entity);
	}

	@Override
	public void batchSave(List<T> entityList) {
		mongoTemplate.insertAll(entityList);
	}
	
	@Override
	public void batchSave(List<T> entityList, String collectionName) {
		mongoTemplate.insert(entityList, collectionName);
	}
}
